#include"stdio.h"
#include"unistd.h"
#include"stdlib.h"
#include"sys/types.h"
#include"sys/wait.h"

int main()
{
  pid_t id = fork();
  if(0 == id)
  {
    //child
    char* const myargv[] = { "otherExe", "-l", "-a", NULL};

    printf("before: I am a process, pid:%d, ppid:%d\n",getpid(),getppid());
    //这类方法的标准写法
    sleep(5);
    //execl(l("/usr/bin/ls","ls","-a","-l", NULL);
    //execl("./otherExe","otherExe", NULL);
    execv("./otherExe",myargv);
    printf("after: I am a process, pid:%d, ppid:%d\n",getpid(),getppid());
    
    exit(1);
  }
  //father
  pid_t ret = waitpid(id, NULL, 0);
  if(ret > 0)
  {
    printf("wait success, father pid:%d, ret id:%d \n", getpid(), ret);
  }

  sleep(5);
  return 0;
}
